import common from './common';
import groups from './groups';
import group from './group';

import {lazy} from 'ice';

export interface RouteType {
  label?: string;
  path: string;
  exact?: boolean;
  component: Function;
}

// 格式化路由
function transformRouter(routes: RouteType[]) {
  return routes.map(route => {
    // 添加懒加载组件
    return {
      ...route,
      component: lazy(route.component)
    }
  })
}

/**
 * 单一页面组件 BasicLayout
 */
export const basicRoutes: RouteType[] = transformRouter([...common]);

/**
 * 首页容器页面  HomeLayout
 */
export const mainRoutes: RouteType[] = transformRouter([...groups, ...group]);

/**
 * 主内容容器页面 MainLayout
 */
export const homeRoutes: RouteType[] = transformRouter([]);
